//client.h

#include <fstream>
#include <iostream>
#include <arpa/inet.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>

using namespace std;

class Client {
public:
	~Client();
	Client(char * ipAddr, int port);
	Client(char * ipAddr, int port, bool debug);
	void connectServer();
	void launchUI();
	
private:
	struct sockaddr_in server;
	int port;
	int socket_handle;
	bool d;
	char * ipAddress;
	
	void init(char * ipAddr, int port, bool debug);
	void free();
	void sendMsg(string * userInput);
	void listMsg(string * userInput);
	void handleListResponse(string response);
	void readMsg(string * userInput);
	void handleReadResponse(string response);
	string sendCommand(string * command);
	char * receiveResponse();
	bool containsNewLine(string * str);
	bool isError(string * response);
	void debug(char * statement);
	void debug(const char * statement);
	void debug(char * statement, char * variable);
	void debug(char * statement, const char * variable);
	void debug(char * statement, int variable);
	void debug(char * statement, string variable);
};
